/**
 * @author : Javier Camelis
 */
/*delete in the future this constant should be defined automaticaly */
var joc_cms = joc_cms || {} ;
joc_cms.URL_FRONTEND = 'http://joc-cms.local:81/'

joc_cms.log = function(){
	arg=arguments;
	if(window.console)for(x in arg){ 
    window.console.log(typeof arg[x] ,arg[x])
    window.console.dir(arg[x])
  }
}
joc_cms.deleteCache = function(){
	if(confirm('Do you want to delete cache ?')){
		data = { data_type : 'service' , module_id : '6' , action : 'delete'}
		$.post(joc_cms.URL_FRONTEND+'index.php',data,function(resp){
			joc_cms.log(resp)
		});
	}
}
joc_cms.state = {}
joc_cms.state.show = function(){
	$('.joc_cms_state').state(arguments)
}
joc_cms.state.hide = function(){
	$('.joc_cms_state').state('hide')
}
joc_cms.dashboard = function(module){
	var dashboard = $('#dashboard'), panel = $('#panel') ;
	joc_cms.log(typeof module,module)
	/*
	$.post(joc_cms.URL_FRONTEND+'index.php',data,function(resp){
		joc_cms.log(resp)
	});
	*/
}
joc_cms.dnd = function(){
  $('li[draggable="true"]').draggable({
    helper: "clone",
    revert: true
  }) ;
  drop = $('div[dropzone="true"]')
  drop.each(function(){
    var self = $(this),
    _accept = self.data('dropaccept'),
    ul = $('ul',self) ;
    joc_cms.log(_accept);
    joc_cms.log(self);
    
    self.droppable({
      accept: 'li.dragid'+_accept+'',
      drop : function(event,ui){
        
      }
    }) ;
  })
}
$(function(){
	$('body').addClass('lightness')
	$('button').button() ;
	state = $('<div class="joc_cms_state">Estado Actual ... </div>');
	$('body').append(state)
	$('.joc_cms_state').state() ;
	$('a','.nav-admin-tool').live('click',function(){
		var href = $(this).attr('href')
		href = href.substring(1)
		joc_cms.dashboard(href)
	})
  joc_cms.dnd();
});